package org.example.demo.controller.common;

import org.example.demo.service.common.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.http.MediaType;

import java.awt.image.BufferedImage;
import java.io.IOException;

@Controller
@RequestMapping(value = "/image")

public class ImageController {

    @Autowired
    private ImageService imageService ;

    @RequestMapping(value = "/get",method = RequestMethod.GET,produces = MediaType.IMAGE_JPEG_VALUE)
    @ResponseBody
    public byte[] getImg(String url) throws IOException{
        return imageService.getImage(url);
    }

}
